/* eslint valid-jsdoc: "off" */

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1726639385162_5568';
  config.middleware = ["errorHandler","auth"];
  config.security = {
    // 关闭 csrf
    csrf: {
      enable: false,
    },
    // 跨域白名单
    domainWhiteList: [],
  };
  config.auth={
    ignore: ["/user/login", "/user/reg"]
  }
  // 允许跨域的方法
  config.cors = {
    origin: "*",
    allowMethods: "GET, PUT, POST, DELETE, PATCH",
  };
  config.valparams = {
    locale: 'zh-cn',
    throwError: true
  };
  config.crypto = {
    secret: "qhdgw@45ncashdaksh2!#@3nxjdas*_672",
  };
  config.jwt={
    secret: "qhdgw@45ncashdaksh2!#@3nxjdas*_672",
  };
  config.sequelize = {
    dialect: "mysql",
    host: "127.0.0.1",
    username: "root",
    password: "",
    port: 3306,
    database: "egg-wangpan",
    // 中国时区
    timezone: "+08:00",
    define: {
      // 取消数据表名复数
      freezeTableName: true,
      // 自动写入时间戳 created_at updated_at
      timestamps: true,
      // 字段生成软删除时间戳 deleted_at
      // paranoid: true,
      createdAt: "created_time",
      updatedAt: "updated_time",
      // deletedAt: 'deleted_time',
      // 所有驼峰命名格式化
      underscored: true,
    },
  };
  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  config.redis = {
    client: {
      port: 6379, // Redis port
      host: "127.0.0.1", // Redis host
      password: "",
      db: 2,
    },
  };
  config.oss = {
    client: {
      accessKeyId: 'LTAI5tFCBhKaDLZpUuyS4pL8',
      accessKeySecret: 'Hzi4BhUwzxfDxvZXWUQbLQDqcWq6gN',
      bucket: 'wangshuo-web1',
      endpoint: 'oss-cn-beijing.aliyuncs.com',
      timeout: '60s',
    },
  };
  
  // 上传格式和大小限制
  config.multipart = {
    // fileSize: '50mb',
    fileSize: 1048576000,
    // mode: 'stream',
    mode: "file",
    fileExtensions: [
      // images
      ".jpg",
      ".jpeg", // image/jpeg
      ".png", // image/png, image/x-png
      ".gif", // image/gif
      ".bmp", // image/bmp
      ".wbmp", // image/vnd.wap.wbmp
      ".webp",
      ".tif",
      ".psd",
      // text
      ".svg",
      ".js",
      ".jsx",
      ".json",
      ".css",
      ".less",
      ".html",
      ".htm",
      ".xml",
      ".doc",
      ".docx",
      // tar
      ".zip",
      ".gz",
      ".tgz",
      ".gzip",
      // video
      ".mp3",
      ".mp4",
      ".avi",
    ],
  };
  return {
    ...config,
    ...userConfig,
  };
};
